package com.songdehuai.motherandchild;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

public class ListFragment extends Fragment {

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_list, container, false);
        init(view);
        return view;
    }

    RecyclerView recyclerView;

    private void init(View view) {
        recyclerView = view.findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        RecyclerListAdapter recyclerListAdapter = new RecyclerListAdapter(getContext(), getList());
        recyclerView.setAdapter(recyclerListAdapter);
    }


    private List<String> getList() {
        List<String> stringList = new ArrayList<>();

        for (int i = 0; i < 100; i++) {
            stringList.add("");
        }
        return stringList;
    }
}
